import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Comparator;


class Que {


    public static void main(String[] args) {
        // String s = "A10";
        // String s2 = "A20";
        // Integer n =  Integer.valueOf(s.substring(1,s.length())) - Integer.valueOf(s2.substring(1,s2.length()));
        // System.out.println(n);


        // Queue<String> q = new LinkedList<>();
        // q.add("a");
        // q.add("b");
        // q.add("c");
        // q.add("d");

        // q.offer("e");
        // q.offer("f");
        // q.offer("g");

        //System.out.println(q.toString()); //[a, b, c, d, e, f, g]

        //System.out.println(q.size());

  


        Queue<User> q = new PriorityQueue<>(new UserComparator());

        q.offer(new User("Bob", "A1"));
        q.offer(new User("Alice", "A2"));
        q.offer(new User("Boss", "V1"));
        q.offer(new User("jim", "A11"));
        q.offer(new User("sbgh", "A10"));
        q.offer(new User("yeue", "A20"));
        System.out.println(q.poll()); // Boss/V1
        System.out.println(q.poll()); // Bob/A1
        System.out.println(q.poll()); // Alice/A2
        System.out.println(q.poll()); // 
        System.out.println(q.poll()); // 
        System.out.println(q.poll()); // null


    }

}


class UserComparator  implements Comparator<User>{
    public int compare(User u1 , User u2){
        if(u1.num.charAt(0) == u2.num.charAt(0)){
            //return u1.num.compareTo(u2.num); // has problem
            //return Integer.valueOf(u1.num.substring(1,u1.num.length()))- Integer.valueOf(u2.num.substring(1,u2.num.length()));
            return Integer.parseInt(u1.num.substring(1,u1.num.length())) - Integer.parseInt(u2.num.substring(1,u2.num.length()));
        }
        if(u1.num.charAt(0) == 'V'){
            return -1;
        }else{
            return 1;
        }

    }
}


class User {
   public final String num; 
   public final String name; 

   public User(String name , String num){
       this.name = name ;
       this.num = num;
   }

   public String toString(){
       return this.name +" - "+ this.num;
   }
   
}

